<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="org.edu.system.DBConnect" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.time.*" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.Calendar" %>
<%@page import="org.edu.system.LogWriter" %>
<%
	String stu_id = (String)(session.getAttribute("UserName"));
	String sql = "SELECT * FROM student WHERE stu_id = '" + stu_id + "'";
	System.out.println(sql);
	
	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{
			//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html>
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="utf-8">
<title>学生后台系统 - 签到</title>
</head>
<body style="width:900px; margin:0 auto;">
<br><br><br><br><br><br><br><br>
<center>
<%
	sql = "select kaoqin from student where stu_id='"+stu_id+"'";
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql);//执行命令
	if(rs.next())
	{
		if(rs.getString("kaoqin").equals("2"))
		{
			out.print("<button type=\"button\" class=\"btn btn-success btn-lg\" onclick=\"window.location.href='./QianDao?stu_id="+stu_id+"'\">点击签到</button>");
		}else if(rs.getString("kaoqin").equals("1"))
		{
			out.print("<h1>你已经签过到了</h1>");
		}else{
			out.print("<h1>暂时无课</h1>");
		}
	}
%>
</center>
</body>
</html>